import { DataTypes, Model } from 'sequelize'
import sequelize from './db'

export interface ITeachCaseComment {
    id: number
    userId: number
    teachCaseId: number
    content: string
    parentId: number
    publishTime: string
}

class TeachCaseComment extends Model {
    declare id: number
    declare userId: number
    declare teachCaseId: number
    declare content: string
    declare parentId: number
    declare publishTime: string
}

TeachCaseComment.init(
    {
        id: {
            type: DataTypes.INTEGER,
            primaryKey: true,
            autoIncrement: true,
        },
        userId: {
            type: DataTypes.INTEGER,
            comment: '用户id',
        },
        teachCaseId: {
            type: DataTypes.INTEGER,
            comment: '案例id',
        },
        parentId: {
            type: DataTypes.INTEGER,
            comment: '父评论id',
        },
        content: {
            type: DataTypes.TEXT('long'),
            comment: '内容',
        },
        publishTime: {
            type: DataTypes.DATE,
            comment: '发布时间',
        },
    },
    {
        // 这是其他模型参数
        sequelize, // 我们需要传递连接实例
        modelName: 'teachcasecomment', // 我们需要选择模型名称
        paranoid: true,
    }
)

export default TeachCaseComment
